class Lily

	class Path < Array
		attr_reader :path, :filename, :suffix

		def initialize(path, parent_directory)
			super()

			@path_base = path
			@array = path.split('/')
			@parent = parent_directory

			parse()
		end

		def category
			cat = @path.sub(/^\/*/, '')
			cat.sub!(/\/*$/, '')
			cat
			(cat == '') ? nil : cat
		end


		private

		def parse
			@suffix = File.extname(@path_base).sub(/^\./, '')
			@basename = File.basename(@path_base)
			@filename = @basename.sub(/\.#{@suffix}$/, '')

			@path = ''
			@path_base.gsub(%r!#{@parent}/(.*?)#{@basename}!) {
				@path = '/' + $1.gsub(/\/*$/, '') if $1 != ''
			}
		end
	end

end
